package com.tanglongan.designPattern.dp20_strategy.demo99;

public class GenericClient {

    /**
     *
     */
    interface IStrategy {
        void algorithm();
    }

    /**
     * 上下文环境
     */
    static class Context {
        private IStrategy strategy;

        public Context(IStrategy strategy) {
            this.strategy = strategy;
        }

        public void algorithm() {
            this.strategy.algorithm();
        }
    }

    /**
     * 具体策略A
     */
    static class ConcreteStrategyA implements IStrategy {
        @Override
        public void algorithm() {
            System.out.println("Strategy A");
        }
    }
    /**
     * 具体策略B
     */
    static class ConcreteStrategyB implements IStrategy {
        @Override
        public void algorithm() {
            System.out.println("Strategy B");
        }
    }
}
